﻿using System;

namespace _06.FindKElementsWithMaxSum
{
    class FindKElementsWithMaxSum
    {
        static void Main()
        {
            Console.Write("Enter lenght of array N=");
            int N = int.Parse(Console.ReadLine());
            Console.Write("Enter number of elements (K<N) K=");
            int K = int.Parse(Console.ReadLine());
            int[] array = new int[N];
            Console.WriteLine("Enter elements of array.The elements must be integer numbers.");
            for (int i = 0; i < N; i++)
            {
                array[i] = int.Parse(Console.ReadLine());
            }
            int sum = 0;
            Array.Sort(array);
            for (int i = N - 1; i > N - 1 - K; i--)
            {
                sum = sum + array[i];
                if (i > N - K)
                {
                    Console.Write("{0}+", array[i]);
                }
                else
                {
                    Console.Write("{0}=", array[i]);
                }
            }
            Console.WriteLine(sum);
        }
    }
}
